package org.microsites.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.microsites.domain.dao.HostDAO;
import org.microsites.domain.model.Entity;
import org.microsites.domain.model.Host;
import org.microsites.service.GroupService;
import org.microsites.service.HostService;

public class HostServiceImpl extends GenericServiceImpl<Host> implements HostService {
	
	private HostDAO hostDAO;
	private GroupService groupService;

	@Override
	public HostDAO getDAO() {
		return hostDAO;
	}

	public void setHostDAO(HostDAO hostDAO) {
		this.hostDAO = hostDAO;
	}

    @Override
    public List<Entity> loadPath(Long id) {
        if (id == null) return new ArrayList<Entity>();

        Host d = this.load(id);
        if (d == null) return new ArrayList<Entity>();
        
        List<Entity> list = groupService.loadPath(d.getGroup());
        list.add(d);

        return list;
    }

    public GroupService getGroupService() {
        return groupService;
    }

    public void setGroupService(GroupService groupService) {
        this.groupService = groupService;
    }
}
